<template>
  <div>
    <div class="ta-search-box">
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="100px"
        size="mini"
      >
        <el-form-item label="账号：" prop="userid">
          <el-input v-model="form.userid" style="width: 340px" />
        </el-form-item>

        <el-form-item label="密码：" prop="password">
          <el-input v-model="form.password" style="width: 340px" />
        </el-form-item>

        <el-form-item label="性别：" prop="sex">
          <el-select
            v-model="form.sex"
            placeholder="请选择性别"
            clearable
            style="width: 340px"
          >
            <el-option
              v-for="item of sexList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="职业：" prop="carrer">
          <el-input v-model="form.carrer" style="width: 340px" />
        </el-form-item>

        <el-form-item label="年龄：" prop="age">
          <el-input v-model="form.age" style="width: 340px" />
        </el-form-item>

        <el-form-item label="身份证号：" prop="identifyId">
          <el-input v-model="form.identifyId" style="width: 340px" />
        </el-form-item>
        <el-form-item label="文件：" prop="hotelTypeId">
          <el-button size="mini" type="primary" @click="handleSubmit">
            提交
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { addCustomUserByAdmin } from "@/api/modules/fingerprint";
export default {
  name: "adduser",
  data() {
    return {
      form: {
        userid: "",
        password: "",
        sex: "",
        carrer: "",
        age: "",
        identifyId: "",
      },
      sexList: [
        {
          value: "0",
          label: "男",
        },
        {
          value: "1",
          label: "女",
        },
      ],
      rules: {
        userid: [
          {
            required: true,
            message: "账户不能为空!",
            trigger: "blur",
          },
        ],
        password: [
          {
            required: true,
            message: "密码不能为空!",
            trigger: "blur",
          },
        ],
      },
      loading: false,
    };
  },
  methods: {
    handleSubmit() {
      console.log("handleSubmit!");
      this.loading = true;
      addCustomUserByAdmin(this.form).then((res) => {
        console.log(res);
        this.loading = false;
        if (res.code == 200) {
          this.$message({
            message: "添加成功",
            type: "success",
          });
        } else {
          this.$message({
            message: res.message,
            type: "error",
          });
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
h1 {
  padding-top: 25px;
  padding-bottom: 25px;
}
</style>
